/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <mutex>
#include <string>
#include <unordered_map>

#include "sle_thing_model_define.h"
namespace OHOS {
namespace iotConnect {
class TimerMgr final
{
public:
    TimerMgr(const TimerMgr&) = delete;
    TimerMgr& operator=(const TimerMgr&) = delete;

    static TimerMgr* GetInstance();
    void SubThingModelWaitReply(const IotcCharState& state);
    //void SubThingModelExecResultRpyly(const SubThingModelExecResult res, const char *svcId, const char *devId, const char *data, const uint32_t len);
    static void SubThingModelTimeroutHandler(union sigval sv);
    static void SubThingModelRecvDataHandler(const uint64_t msgSeq, const uint8_t *data, uint32_t len);

private:
    TimerMgr() noexcept = default;

private:
    static std::mutex mutex_;
    constexpr static uint32_t timeout_ = 10;
    static uint64_t msgSeq;
    static std::unordered_map<uint64_t, MessageTimerAttr*> um_timers_;
};
}
}
